\hypertarget{config_8h_source}{}\doxysection{config.\+h}

\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 \textcolor{comment}{//文件类型}}
\DoxyCodeLine{3 \textcolor{preprocessor}{\#define BINFILE 0;}}
\DoxyCodeLine{4 \textcolor{preprocessor}{\#define ASCFILE 1;}}
\DoxyCodeLine{5 }
\DoxyCodeLine{6 \textcolor{comment}{//命令}}
\DoxyCodeLine{7 \textcolor{preprocessor}{\#define LS 1}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#define PWD 2}}
\DoxyCodeLine{9 \textcolor{preprocessor}{\#define CD 3}}
\DoxyCodeLine{10 \textcolor{preprocessor}{\#define PUT 4}}
\DoxyCodeLine{11 \textcolor{preprocessor}{\#define GET 5}}
\DoxyCodeLine{12 \textcolor{preprocessor}{\#define MKDIR 6}}
\DoxyCodeLine{13 \textcolor{preprocessor}{\#define RMDIR 7}}
\DoxyCodeLine{14 \textcolor{preprocessor}{\#define DELETE 8}}
\DoxyCodeLine{15 \textcolor{preprocessor}{\#define QUIT 9}}
\DoxyCodeLine{16 \textcolor{preprocessor}{\#define LPWD 10}}
\DoxyCodeLine{17 \textcolor{preprocessor}{\#define LLS 11}}
\DoxyCodeLine{18 \textcolor{preprocessor}{\#define LCD 12}}
\DoxyCodeLine{19 \textcolor{preprocessor}{\#define CHMOD 13}}
\DoxyCodeLine{20 \textcolor{preprocessor}{\#define HELP 14}}
\DoxyCodeLine{21 \textcolor{preprocessor}{\#define ERROR -\/1}}
\DoxyCodeLine{22 \textcolor{preprocessor}{\#define NO\_AUTH -\/2}}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 \textcolor{comment}{// FTP 工作方式mode}}
\DoxyCodeLine{25 \textcolor{comment}{/*}}
\DoxyCodeLine{26 \textcolor{comment}{        Port模式FTP 客户端首先和FTP服务器的TCP 21端口建立连接，通过这个通道发送命令，}}
\DoxyCodeLine{27 \textcolor{comment}{        客户端需要接收数据的时候在这个通道上发送PORT命令。}}
\DoxyCodeLine{28 \textcolor{comment}{        PORT命令包含了客户端用什么端口接收数据。在传送数据的时候，服务器端通过自己的TCP 20端口连接至客户端的指定端口发送数据。}}
\DoxyCodeLine{29 \textcolor{comment}{        FTP server必须和客户端建立一个新的连接用来传送数据。}}
\DoxyCodeLine{30 \textcolor{comment}{        这种方式下是客户端和服务器建立控制连接，服务器向客户端建立数据连接，}}
\DoxyCodeLine{31 \textcolor{comment}{        其中，客户端的控制连接和数据连接的端口号是大于1024的两个端口号（临时端口），}}
\DoxyCodeLine{32 \textcolor{comment}{        而FTP服务器的数据端口为20，控制端口为21}}
\DoxyCodeLine{33 \textcolor{comment}{*/}}
\DoxyCodeLine{34 \textcolor{preprocessor}{\#define PORT 0 }\textcolor{comment}{//主动模式，客户端发送PORT命令到服务器}}
\DoxyCodeLine{35 \textcolor{comment}{/*}}
\DoxyCodeLine{36 \textcolor{comment}{Passive模式在建立控制通道的时候和Port模式类似，但建立连接后发送的不是Port命令，而是Pasv命令。}}
\DoxyCodeLine{37 \textcolor{comment}{FTP服务器收到Pasv命令后，随机打开一个临时端口（也叫自由端口，端口号大于1023小于65535），并且通知客户端在这个端口上传送数据的请求。}}
\DoxyCodeLine{38 \textcolor{comment}{客户端连接FTP服务器此端口，然后FTP服务器将通过这个端口进行数据的传送，这个时候FTP server不再需要建立一个新的和客户端之间的连接。}}
\DoxyCodeLine{39 \textcolor{comment}{}}
\DoxyCodeLine{40 \textcolor{comment}{这种情况下的连接都是由客户端向服务器发起的}}
\DoxyCodeLine{41 \textcolor{comment}{*/}}
\DoxyCodeLine{42 \textcolor{preprocessor}{\#define PASV 1 }\textcolor{comment}{//被动模式，客户端发送PASV命令到服务器}}
\DoxyCodeLine{43 }
\DoxyCodeLine{44 \textcolor{comment}{//服务器返回消息}}
\DoxyCodeLine{45 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo220[] = \textcolor{stringliteral}{"{}220 myFTP Server ready...\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{46 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo230[] = \textcolor{stringliteral}{"{}230 User logged in, proceed.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{47 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo331[] = \textcolor{stringliteral}{"{}331 User name okay, need password.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{48 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo221[] = \textcolor{stringliteral}{"{}221 Goodbye!\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{49 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo150[] = \textcolor{stringliteral}{"{}150 File status okay; about to open data connection.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{50 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo226[] = \textcolor{stringliteral}{"{}226 Closing data connection.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{51 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo200[] = \textcolor{stringliteral}{"{}200 Command okay.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{52 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo215[] = \textcolor{stringliteral}{"{}215 Unix Type FC5.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{53 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo213[] = \textcolor{stringliteral}{"{}213 File status.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{54 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo211[] = \textcolor{stringliteral}{"{}211 System status, or system help reply.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{55 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo350[] = \textcolor{stringliteral}{"{}350 Requested file action pending further information.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{56 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo530[] = \textcolor{stringliteral}{"{}530 Not logged in.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{57 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo531[] = \textcolor{stringliteral}{"{}531 Not root client. Anonymous client.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{58 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo441[] = \textcolor{stringliteral}{"{}441 File\_type wrong.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{59 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo425[] = \textcolor{stringliteral}{"{}425 Something is wrong, can't start the active connection... \(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{60 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo227[] = \textcolor{stringliteral}{"{}227 Entering Passive Mode\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{61 \textcolor{keyword}{static} \textcolor{keywordtype}{char} serverInfo[] = \textcolor{stringliteral}{"{}202 Command not implemented, superfluous at this site.\(\backslash\)r\(\backslash\)n"{}};}
\DoxyCodeLine{62 }
\DoxyCodeLine{63 \textcolor{comment}{//其它配置信息}}
\DoxyCodeLine{64 \textcolor{preprocessor}{\#define FPT\_SERVER\_PORT 21}}
\DoxyCodeLine{65 \textcolor{preprocessor}{\#define MAX\_INFO 1024}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\#define DIR\_INFO 100}}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#define MSG\_INFO 100}}
\DoxyCodeLine{68 \textcolor{preprocessor}{\#define LISTEN\_QENU 5}}
\DoxyCodeLine{69 \textcolor{preprocessor}{\#define MAX\_LISTEN 20 }\textcolor{comment}{//同时进行最大监听数}}
\DoxyCodeLine{70 }
\DoxyCodeLine{71 \textcolor{comment}{//复制时保留文件的位序，逐位拷贝原始文件而不管内容}}
\DoxyCodeLine{72 \textcolor{preprocessor}{\#define BINARY 0}}
\DoxyCodeLine{73 \textcolor{comment}{//复制时候会进行调整，主要体现为对不同操作系统的回车/换行/结束符等进行转译。}}
\DoxyCodeLine{74 \textcolor{comment}{//假定用户正在拷贝的文件包含的简单ASCII码文本，如果在远程机器上运行的不是UNIX，}}
\DoxyCodeLine{75 \textcolor{comment}{//当文件传输时ftp通常会自动地调整文件的内容以便于把文件解释成另外那台计算机存储文本文件的格式。}}
\DoxyCodeLine{76 \textcolor{preprocessor}{\#define ASCII 1}}
\DoxyCodeLine{77 }
\DoxyCodeLine{78 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\mbox{\hyperlink{structMsg}{Msg}}}
\DoxyCodeLine{79 \{}
\DoxyCodeLine{80         \textcolor{keywordtype}{int} file\_type;}
\DoxyCodeLine{81         \textcolor{keywordtype}{int} mode;                    \textcolor{comment}{//用于区分PORT和PASV}}
\DoxyCodeLine{82         \textcolor{keywordtype}{int} ftp\_control\_sock;        \textcolor{comment}{//端口控制sock}}
\DoxyCodeLine{83         \textcolor{keywordtype}{int} ftp\_data\_sock;           \textcolor{comment}{//端口数据sock, (文件传输通道), PORT模式下您需要给我一个新的sock}}
\DoxyCodeLine{84         \textcolor{keywordtype}{char} control\_info[MAX\_INFO]; \textcolor{comment}{//控制信息}}
\DoxyCodeLine{85 \} \mbox{\hyperlink{structMsg}{Msg}};}

\end{DoxyCode}
